#include <QCoreApplication>
#include <QTimer>
#include <QDebug>
#include "network/DisconnectLogger.h"

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);
    
    qDebug() << "开始测试断开连接日志记录器...";
    
    // 测试不同类型的日志记录
    DisconnectLogger::instance()->logHeartbeatTimeout("ROBOT001", "192.168.1.100", 3, 15000, 25);
    
    DisconnectLogger::instance()->logRegisterTimeout("192.168.1.101", 30000);
    
    DisconnectLogger::instance()->logDatabaseTimeout("ROBOT002", "2025-10-30 15:30:00", 60000);
    
    DisconnectLogger::instance()->logManualDisconnect("ROBOT003", "192.168.1.102", "管理员手动断开", 45000);
    
    DisconnectLogger::instance()->logSocketError("ROBOT004", "192.168.1.103", "连接重置", 20000);
    
    DisconnectLogger::instance()->logUserRequest("USER001", "ROBOT005", "用户主动断开连接", 35000);
    
    // 使用通用日志方法
    DisconnectLogger::instance()->logDisconnect(
        DisconnectType::NetworkError,
        "网络异常断开",
        "CONN123",
        "ROBOT006",
        "192.168.1.104",
        8080,
        DisconnectResult::Failed,
        "网络超时导致断开",
        18000,
        30,
        "额外信息：网络质量差"
    );
    
    qDebug() << "日志记录测试完成，等待文件写入...";
    
    // 等待一段时间确保日志写入完成
    QTimer::singleShot(2000, &app, &QCoreApplication::quit);
    
    return app.exec();
}